﻿@using LKVMLMADMIN.Models;
@using PagedList.Mvc;
@using System.Globalization;
@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@using (Html.BeginForm("CauHinhHoaHong", "CongCu", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-inline" }))
{
    <div id="wrapper">
        <div class="clear-fix"></div>
        <div class="row" style=" min-height: 110px; padding-left: 30px; ">          
                <h3 class="page-header">Cấu hình hoa hồng</h3>           
        </div>   
        <div class="row">
            <div class="col-lg-12">
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                            <thead>
                                <tr style="font-family:'Times New Roman'">
                                    <th>STT</th>                                                                 
                                    <th>Tên hoa hồng</th>
                                    <th>Mô tả</th>
                                    <th> Tính toán hàng tháng</th>
                                    <th>Trạng thái</th>                                 
                                </tr>
                            </thead>
                            <tbody style="font-family:'Times New Roman'">
                                @{int j = 0;}
                                @foreach (var item in ViewBag.List)
                                {
                                    j++;
                                    <tr>
                                        <td>@j</td>
                                        <td>@item.CommissionName</td>  
                                        <td>@item.CommissionDesc</td>  
                                        <td>
                                            @{
                                                if (item.Monthly == true)
                                                {

                                                    <input name="Check" type="checkbox" checked="checked" disabled="disabled"/>
                                                }
                                                else
                                                {
                                                    <input name="Check" type="checkbox" disabled="disabled"/>
                                                }
                                              }
                                        </td>                                  
                                        <td>
                                            @{                                                 
                                                if(item.Status == true)
                                                { 
                                                    
                                                    <input name="Check" type="checkbox" checked="checked" id="CG_@item.CommissionName" />
                                                }
                                                else
                                                {
                                                    <input name="Check" type="checkbox" id="CG_@item.CommissionName" />
                                                }
                                              }
                                        </td>                             
                                        
                                    </tr>
                                }

                            </tbody>
                        </table>
                    </div>
                    <button type="reset" class="btn_submit btn btn-default pull-right" style="margin:3px;">Hủy</button>
                    <button type="submit" class="btn_submit btn btn-default pull-right" style="margin:3px;">Lưu</button>                  
                </div>
            </div>
        </div>
    </div>
}
<script>
    $(document).ready(function () {
        $('input:checkbox').change(function (e) {
            e.preventDefault();
            var commission = $(this).attr('id').substr(3);
            var _val = $(this).prop('checked');
            $.ajax({
                dataType: "json",
                url: "/CongCu/ChangeSatusCommission?commission=" + commission + "&val="+_val,
                success: function (data) {

                }
            });
        })
    });

</script>